package main

import "sync"

type Info struct {
	mu  sync.Mutex
	Str string
}

func main() {
	info := Info{sync.Mutex{}, "str"}
	update(&info)
}

func update(info *Info) {
	info.mu.Lock() //获取锁
	info.Str = "dfasf"
	info.mu.Unlock() //释放锁
}
